package com.gxa.clientkill.service.Impl;

import com.gxa.clientkill.mapper.TicketMapper;
import com.gxa.clientkill.pojo.Ticket;
import com.gxa.clientkill.service.TicketService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Jun
 * @version 1.0
 * @date 2020/11/12 9:35
 */

@Service("ticketService")
public class TicketServiceImpl implements TicketService {

    @Resource
    TicketMapper ticketMapper;


    @Override
    public Integer add(Ticket ticket) {
        return ticketMapper.insertSelective(ticket);
    }

    @Override
    public Integer del(Integer id) {
        return ticketMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Ticket> list() {
        return ticketMapper.selectAll();
    }

    @Override
    public Integer send(Integer id) {
        Ticket ticket = ticketMapper.selectByPrimaryKey(id);
        ticket.setState(1);
        return ticketMapper.updateByPrimaryKeySelective(ticket);
    }

    @Override
    public Integer update(Ticket ticket) {
        return ticketMapper.updateByPrimaryKeySelective(ticket);
    }

    @Override
    public Ticket sel(Integer id) {
        return ticketMapper.selectByPrimaryKey(id);
    }
}
